package main

import (
	"fmt"
	"bytes"
)

func main() {
	a := make([]byte, 0, 32)
	fmt.Printf("addr: %p; len: %d\n", a, len(a))
	
	a = append(a, 0xff, 0xff)
	fmt.Printf("addr: %p; len: %d\n", a, len(a))
	
	a = a[:0]
	fmt.Printf("addr: %p; len: %d; cap: %d\n", a, len(a), cap(a))
	
	a = append(a, 97, 98)
	fmt.Printf("addr: %p; len: %d; cap: %d\n", a, len(a), cap(a))
	
	str := string(a)
	fmt.Printf("addr: %p; len: %d; str: %s\n", &str, len(str), str)
	fmt.Printf("[]byte begin with 'ab': %v\n", bytes.HasPrefix(a, []byte("ab")))
	fmt.Printf("[]byte begin with 'ab': %v\n", bytes.HasPrefix(a, []byte{97, 98}))
	
	a = a[:0]
	fmt.Printf("addr: %p; len: %d; cap: %d\n", a, len(a), cap(a))
	a = append(a, []byte("中文")...)
	fmt.Printf("string: %s\n", a)
	fmt.Printf("addr: %p; len: %d; cap: %d\n", a, len(a), cap(a))
	fmt.Printf("[]byte begin with '中文': %v\n", bytes.HasPrefix(a, []byte("中文")))
	fmt.Printf("[]byte end with '中文': %v\n", bytes.HasSuffix(a, []byte("中文")))
}